#ifndef _UIACCELEROMETER_H_
#define _UIACCELEROMETER_H_

#include <QObject>

typedef qreal UIAccelerationValue;

class UIAccelerationPrivate;
class UIAcceleration {
    friend class UIAccelerometer;

    public:
        UIAcceleration();
        ~UIAcceleration();

        bool isNull (void) const;

        UIAccelerationValue x (void) const;
        UIAccelerationValue y (void) const;
        UIAccelerationValue z (void) const;

        qreal timestamp (void) const;

    private:
        void setAcceleration (UIAccelerationValue x, 
                              UIAccelerationValue y, 
                              UIAccelerationValue z);
        void setAcceleration (const UIAcceleration& acceleration);

    private:
        UIAccelerationPrivate *d;
};

class UIAccelerometerPrivate;
class UIAccelerometer : public QObject {
    Q_OBJECT

    public:
        static UIAccelerometer *sharedAccelerometer (void);

    public:
        qreal updateInterval (void) const;
        void setUpdateInterval (qreal secs);

        bool enabled (void) const;
        void setEnabled (bool enabled);

        bool isShaking (void) const;
        bool isShaking (qreal threshold) const;

        UIAcceleration *acceleration (void) const;
        void acceleration (UIAccelerationValue *x,
                           UIAccelerationValue *y,
                           UIAccelerationValue *z) const;

    Q_SIGNALS:
        void accelerate (UIAcceleration *acceleration);
        void shaked (void);

    private Q_SLOTS:
        void accelerate (qreal x, qreal y, qreal z);

    public:
        UIAccelerometer (QObject *parent = 0);
        ~UIAccelerometer();

    private:
        UIAccelerometerPrivate *d;
};

#endif /* !_UIACCELEROMETER_H_ */

